﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;
using System.Reflection;
//using 

namespace Phong_CTSV
{
    public struct Position
    {
        int column;
        int row;
        public Position(int x, int y)
        {
            row = x;
            column = y;
        }
        public int Column
        {
            get{return column;}
            set{column = value;}
        }
        public int Row
        {
            get{return row;}
            set{row = value;}
        }
    }
    public class Output_File
    {
        static List<Position> listPos = new List<Position>{new Position(1, 1), new Position(0, 0)};
        public Output_File() 
        { 
    
        }

        public static List<ArrayList> Ouput(string formName, string uniName,int year)
        {
            QuerrySQL _querry = new QuerrySQL();
            List<ArrayList> _arraylist = new List<ArrayList>();
            List<Columns_Header> _col_header = _querry.Select_ColumnsHeaderByForm(formName);
            List<Rows_Header> _row_header = _querry.Select_RowsHeaderByForm(formName);
            ArrayList _lable_row = new ArrayList();
            if (_lable_row.Count > 0)
            {
                _lable_row.Add("");
                foreach (Rows_Header row_header in _row_header)
                    _lable_row.Add(row_header.Name);
                _arraylist.Add(_lable_row);
            }
            foreach (Columns_Header col_header in _col_header)
            { 
                int uni_ID = (int)_querry.Select_University(uniName).ID;
                List<Data_Table> data = _querry.Select_Data_Columns((int)col_header.Form_id, uni_ID, (int)col_header.ID, year);
                ArrayList _temp = new ArrayList(data);
                _temp.Insert(0, col_header.Name);
                _arraylist.Add(_temp);
            }
            return _arraylist;

        }
/*
        public static void WriteFileExcel(string formName, string uinName, int year, string saveFile)
        {
            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("content-disposition",
             "attachment;filename=GridViewExport.xls");
            Response.Charset = "";
            Response.ContentType = "application/vnd.ms-excel";
            StringWriter sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);
            // Bỏ phân trang - Nếu chỉ muỗn Export Trang hiện hành thì chọn =true
            MyGridview.AllowPaging = false;
            MyGridview.DataBind();
            MyGridview.RenderControl(hw);
            //Thay đổi Style
            string style = @"";
            Response.Write(style);
            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();
        }*/
    }
}